<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class DataBLUController extends BaseController {
    /*
     * Konstruktor
     */

    public function __construct($registry) {
        parent::__construct($registry);
    }

    /*
     * Index
     */

    public function index() {
        
    }

    /*
      public function infoSP2D() {
      $d_spm = new DataSPM($this->registry);
      d_spm->get_spm_filter();
      //var_dump($d_spm1->get_sppm_filter($filter));
      $this->view->render('kppn/isianSPM');
      }
     */

    public function KarwasBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        
		
		
		if (isset($_POST['submit_file'])) {
           
			 if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "SUBSTR(KDKPPN,1,3) = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
            } 		
			
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "SATKER = '" . $_POST['kdsatker'] . "'";
				$this->view->nmsatker = $d_spm1->get_kdsatker_blu($_POST['kdsatker']);
            }
			
			if ($_POST['Rumpun'] != '') {
				
				if ($_POST['Rumpun'] == 'Kesehatan'){
					 $filter[$no++] = "RUMPUN = 'Kesehatan'";
				}
				if ($_POST['Rumpun'] == 'Pendidikan'){
					 $filter[$no++] = "RUMPUN = 'Pendidikan'";
				}
				if ($_POST['Rumpun'] == 'Pengelola'){
					 $filter[$no++] = "RUMPUN = 'Pengelola Dana'";
				}
				if ($_POST['Rumpun'] == 'Kawasan'){
					 $filter[$no++] = "RUMPUN = 'Kawasan'";
				}
				if ($_POST['Rumpun'] == 'Barang'){
					 $filter[$no++] = "RUMPUN = 'Barang Jasa Lainnya'";
				}
				$this->view->Rumpun = $_POST['Rumpun'];
                
            }
       
		}
		
		if (Session::get('role') == KPPN) {
			$filter[$no++] = "KDKPPN = '" . Session::get('id_user')."'";			
        }
		
		 $d_kppn_list = new DataUser($this->registry);
         $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
			
		$this->view->data = $d_spm1->get_rekap_sp3b($filter);
        
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        //var_dump($d_last_update->get_last_updatenya($d_spm1->get_table1()));
		
		$d_log->tambah_log("Sukses");
		
		
        $this->view->render('blu/karwasBLU');
    }
	
	public function DaftarSP3($bulan, $satker) {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        
		
		if ($bulan != '') {           
                $filter[$no++] = " TO_CHAR(CHECK_DATE,'MM') =  '" .$bulan. "'";
				$this->view->bulan = $bulan;				
        }
		
		if ($satker != '') {           
                $filter[$no++] = " SUBSTR(INVOICE_NUM,8,6) =  '" .$satker. "'";
				$this->view->satker = $satker;
				
        }
		
		
		if (isset($_POST['submit_file'])) {
            if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "KPPN_CODE = '" . $_POST['kdkppn']."'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
				
            } else {
                $filter[$no++] = "KPPN_CODE = '" . Session::get('id_user')."'";
            }
									
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "SATKER_CODE = '" . $_POST['kdsatker'] . "'";
				
            }
       
		}
		
		if (Session::get('role') == KPPN) {
			$filter[$no++] = "KDKPPN = '" . Session::get('id_user')."'";			
        }
		$this->view->data = $d_spm1->get_daftar_sp3b($filter);
		$this->view->data1 = $d_spm1->get_kdsatker_blu($satker);
        
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table2());
		
		$d_log->tambah_log("Sukses");
		
		
        $this->view->render('blu/daftarSP3');
    }
	
	public function CariSP3B() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        
		
		
		if (isset($_POST['submit_file'])) {
            /*if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "KPPN_CODE = '" . $_POST['kdkppn']."'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
				
            } else {
                $filter[$no++] = "KPPN_CODE = '" . Session::get('id_user')."'";
            }*/
						
			
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "SEGMENT1 = '" . $_POST['kdsatker'] . "'";
				$this->view->kdsatkerr = $_POST['kdsatker'];
            }
			if ($_POST['invoice'] != '') {
                $filter[$no++] = "INVOICE_NUM = '" . $_POST['invoice'] . "'";
				$this->view->invoice = $_POST['invoice'];
            }
			
			if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {
                $filter[$no++] = "TO_CHAR(INVOICE_DATE,'YYYYMMDD') BETWEEN '" . date('Ymd', strtotime($_POST['tgl_awal'])) . "' AND '" . date('Ymd', strtotime($_POST['tgl_akhir'])) . "'";

                $this->view->d_tgl_awal = $_POST['tgl_awal'];
                $this->view->d_tgl_akhir = $_POST['tgl_akhir'];
            }
		$this->view->data = $d_spm1->get_cari_sp3b($filter);
		}
		
		if (Session::get('role') == KPPN) {
			$filter[$no++] = "KDKPPN = '" . Session::get('id_user')."'";			
        }
		
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table3());
		
		$d_log->tambah_log("Sukses");
		
		
        $this->view->render('blu/cariSP3');
    }
	
	public function DataRealisasiBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
		
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        if (isset($_POST['submit_file'])) {
            /* if ($_POST['kdkppn'] != '') {
				if ($_POST['kdkppn'] != 'SEMUA') {
					$filter[$no++] = "A.KPPN = '" . $_POST['kdkppn'] . "'";
					$d_kppn = new DataUser($this->registry);
					$this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
					$this->view->d_kd_kppn = $_POST['kdkppn'];
				}
            } else {
                $filter[$no++] = "A.KPPN = '" . Session::get('id_user') . "'";
            } */

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.SATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->satker_code = $_POST['kdsatker'];
            }
			if ($_POST['SumberDana'] != '') {
                $filter[$no++] = "SUBSTR(A.DANA,1,1) = '" . $_POST['SumberDana'] . "'";
                $this->view->SumberDana = $_POST['SumberDana'];
            }
			if ($_POST['Rumpun'] != '') {
				
				if ($_POST['Rumpun'] == 'Kesehatan'){
					 $filter[$no++] = "C.RUMPUN = 'Kesehatan'";
				}
				if ($_POST['Rumpun'] == 'Pendidikan'){
					 $filter[$no++] = "C.RUMPUN = 'Pendidikan'";
				}
				if ($_POST['Rumpun'] == 'Pengelola'){
					 $filter[$no++] = "C.RUMPUN = 'Pengelola Dana'";
				}
				if ($_POST['Rumpun'] == 'Kawasan'){
					 $filter[$no++] = "C.RUMPUN = 'Kawasan'";
				}
				if ($_POST['Rumpun'] == 'Barang'){
					 $filter[$no++] = "C.RUMPUN = 'Barang Jasa Lainnya'";
				}
				$this->view->Rumpun = $_POST['Rumpun'];
                
            }
            			
			
        }

        //----------------------------------------------------
        $this->view->data = $d_spm1->get_realisasi_blu($filter);
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table4());

        $d_log->tambah_log("Sukses");

        $this->view->render('blu/RealisasiBLU');
    }
	
	public function DataRealisasiBelanjaBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
		
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        if (isset($_POST['submit_file'])) {
            /* if ($_POST['kdkppn'] != '') {
				if ($_POST['kdkppn'] != 'SEMUA') {
					$filter[$no++] = "A.KPPN = '" . $_POST['kdkppn'] . "'";
					$d_kppn = new DataUser($this->registry);
					$this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
					$this->view->d_kd_kppn = $_POST['kdkppn'];
				}
            } else {
                $filter[$no++] = "A.KPPN = '" . Session::get('id_user') . "'";
            } */

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.SATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->satker_code = $_POST['kdsatker'];
            }
			if ($_POST['SumberDana'] != '') {
                $filter[$no++] = "SUBSTR(A.DANA,1,1) = '" . $_POST['SumberDana'] . "'";
                $this->view->SumberDana = $_POST['SumberDana'];
            }
			if ($_POST['Rumpun'] != '') {
				
				if ($_POST['Rumpun'] == 'Kesehatan'){
					 $filter[$no++] = "C.RUMPUN = 'Kesehatan'";
				}
				if ($_POST['Rumpun'] == 'Pendidikan'){
					 $filter[$no++] = "C.RUMPUN = 'Pendidikan'";
				}
				if ($_POST['Rumpun'] == 'Pengelola'){
					 $filter[$no++] = "C.RUMPUN = 'Pengelola Dana'";
				}
				if ($_POST['Rumpun'] == 'Kawasan'){
					 $filter[$no++] = "C.RUMPUN = 'Kawasan'";
				}
				if ($_POST['Rumpun'] == 'Barang'){
					 $filter[$no++] = "C.RUMPUN = 'Barang Jasa Lainnya'";
				}
				
               
            }
            			
			
        }

        //----------------------------------------------------
        $this->view->data = $d_spm1->get_realisasi_belanja_blu($filter);

        //$d_last_update = new DataLastUpdate($this->registry);
        //$this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");

        $this->view->render('blu/RealisasiBelanjaBLU');
    }
	
	public function DataRealisasiBelanjaModalBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
		
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        if (isset($_POST['submit_file'])) {
            /* if ($_POST['kdkppn'] != '') {
				if ($_POST['kdkppn'] != 'SEMUA') {
					$filter[$no++] = "A.KPPN = '" . $_POST['kdkppn'] . "'";
					$d_kppn = new DataUser($this->registry);
					$this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
					$this->view->d_kd_kppn = $_POST['kdkppn'];
				}
            } else {
                $filter[$no++] = "A.KPPN = '" . Session::get('id_user') . "'";
            } */

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "A.SATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->satker_code = $_POST['kdsatker'];
            }
			if ($_POST['SumberDana'] != '') {
                $filter[$no++] = "SUBSTR(A.DANA,1,1) = '" . $_POST['SumberDana'] . "'";
                $this->view->SumberDana = $_POST['SumberDana'];
            }
			if ($_POST['Rumpun'] != '') {
				
				if ($_POST['Rumpun'] == 'Kesehatan'){
					 $filter[$no++] = "C.RUMPUN = 'Kesehatan'";
				}
				if ($_POST['Rumpun'] == 'Pendidikan'){
					 $filter[$no++] = "C.RUMPUN = 'Pendidikan'";
				}
				if ($_POST['Rumpun'] == 'Pengelola'){
					 $filter[$no++] = "C.RUMPUN = 'Pengelola Dana'";
				}
				if ($_POST['Rumpun'] == 'Kawasan'){
					 $filter[$no++] = "C.RUMPUN = 'Kawasan'";
				}
				if ($_POST['Rumpun'] == 'Barang'){
					 $filter[$no++] = "C.RUMPUN = 'Barang Jasa Lainnya'";
				}
				
                $this->view->Rumpun = $_POST['Rumpun'];
            }
            			
			
        }

        //----------------------------------------------------
        $this->view->data = $d_spm1->get_realisasi_belanja_modal_blu($filter);

        //$d_last_update = new DataLastUpdate($this->registry);
        //$this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $d_log->tambah_log("Sukses");

        $this->view->render('blu/RealisasiBelanjaModalBLU');
    }
	
	public function DataRealisasiPenerimaanBLU() {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if (isset($_POST['submit_file'])) {

            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "B.KDSATKER = '" . $_POST['kdsatker'] . "'";
                $this->view->kdsatker = $_POST['kdsatker'];
            }
            if ($_POST['nmsatker'] != '') {
                $filter[$no++] = " UPPER(B.NMSATKER) LIKE UPPER('%" . $_POST['nmsatker'] . "%')";
                $this->view->d_nm_satker = $_POST['nmsatker'];
            }
            if ($_POST['kdba'] != '') {
                $filter[$no++] = "B.BA = '" . $_POST['kdba'] . "'";
                $this->view->kdeselon1 = $_POST['kdba'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

      
        $this->view->data = $d_spm1->get_pendapatan_persatker_blu_filter($filter);
        
        $d_log->tambah_log("Sukses");

        $this->view->render('blu/DataRealisasiPenerimaanSatkerBLU');
    }
	
	public function DataRealisasiPenerimaanAkunBLU($eselon1 = null, $satker = null) {
        $d_spm1 = new DataRealisasiPendapatan($this->registry);
        $filter = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));

        if ($eselon1 != null) {
			 $filter[$no++] = "BAES1 = '" . $eselon1 . "'";
            
			$this->view->eselon1 = $eselon1;
        }
		
		if ($satker != null) {
            $filter[$no++] = "KDSATKER = '" . $satker . "'";
            $this->view->d_kd_satker = $satker;
        }

        if (isset($_POST['submit_file'])) {

            
           if ($_POST['bln_awal'] != '' && $_POST['bln_akhir'] != '') {
                $filter[$no++] = "(A.PERIODE BETWEEN  '" . $_POST['bln_awal'] . "' AND '". $_POST['bln_akhir'] ."' OR A.PERIODE = 'B')";
                $this->view->bln_awal = $_POST['bln_awal'];
				$this->view->bln_akhir = $_POST['bln_akhir'];
            }
        }

        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());

        $this->view->data = $d_spm1->get_blu_pendapatan_filter($filter);		
			// script lama dari gl_balances_v
			//$this->view->data = $d_spm1->get_ba_pendapatan_filter($filter);
        
        $d_log->tambah_log("Sukses");

        $this->view->render('blu/DataRealisasiPenerimaanBLU');
    }
	
	public function DataLoBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
		$filter2 = array();
        $no = 0;
        //untuk mencatat log user
        $d_log = new DataLog($this->registry);
        $d_log->set_activity_time_start(date("d-m-Y h:i:s"));
		
		if (isset($_POST['submit_file'])) {
			if ($_POST['tgl_awal'] != '' AND $_POST['tgl_akhir'] != '') {
					$filter[$no++] = "TO_CHAR(TGLPOST,'MMDD') BETWEEN '" . date('md', strtotime($_POST['tgl_awal'])) . "' AND '" . date('md', strtotime($_POST['tgl_akhir'])) . "'";
					$filter2[$no++] = "TO_CHAR(TGLPOST,'MMDD') BETWEEN '" . date('md', strtotime($_POST['tgl_awal'])) . "' AND '" . date('md', strtotime($_POST['tgl_akhir'])) . "'";
					$this->view->d_tgl_awal = $_POST['tgl_awal'];
					$this->view->d_tgl_akhir = $_POST['tgl_akhir'];
				}
			else 	{
					$filter2[$no++] = " TO_CHAR(TGLPOST,'MMDD') <= TO_CHAR(SYSDATE,'MMDD')";
			
			}
			if ($_POST['kdsatker']) {
				$filter[$no++] = "SATKER = '" . $_POST['kdsatker'] . "'";
				$filter2[$no++] = "SATKER = '" . $_POST['kdsatker'] . "'";
				$this->view->d_kd_satker = $_POST['kdsatker'];
				$this->view->data3 = $d_spm1->get_kdsatker_blu( $_POST['kdsatker'] );
			}
			$this->view->data2 = $d_spm1->get_satker_blu($filter );
			$this->view->data = $d_spm1->get_lo_blu_harian($filter ,$filter2);
		}
		
		$d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
		
        $this->view->render('blu/LO');
    }
	
	public function SaldoKasBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        				
		if (isset($_POST['submit_file'])) {
           
			 if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "SUBSTR(KDKPPN,1,3) = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
            } 		
			
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['kdsatker'] . "'";
				$this->view->nmsatker = $d_spm1->get_kdsatker_blu($_POST['kdsatker']);
            }
			
			if ($_POST['Rumpun'] != '') {
				
				if ($_POST['Rumpun'] == 'Kesehatan'){
					 $filter[$no++] = "RUMPUN = 'Kesehatan'";
				}
				if ($_POST['Rumpun'] == 'Pendidikan'){
					 $filter[$no++] = "RUMPUN = 'Pendidikan'";
				}
				if ($_POST['Rumpun'] == 'Pengelola'){
					 $filter[$no++] = "RUMPUN = 'Pengelola Dana'";
				}
				if ($_POST['Rumpun'] == 'Kawasan'){
					 $filter[$no++] = "RUMPUN = 'Kawasan'";
				}
				if ($_POST['Rumpun'] == 'Barang'){
					 $filter[$no++] = "RUMPUN = 'Barang Jasa Lainnya'";
				}
				$this->view->Rumpun = $_POST['Rumpun'];
                
            }
       
		}
		
		
		 $d_kppn_list = new DataUser($this->registry);
         $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();
			
		$this->view->data = $d_spm1->get_saldo_kas_blu($filter);
        
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        //var_dump($d_last_update->get_last_updatenya($d_spm1->get_table1()));
		
		$d_log->tambah_log("Sukses");
		
		
        $this->view->render('blu/SaldoKasBLU');
    }
	
	public function MonitoringAkunBLU() {
        $d_spm1 = new DataBLU($this->registry);
        $filter = array();
        $no = 0;
		
		//untuk mencatat log user
        $d_log = new DataLog($this->registry);
		$d_log->set_activity_time_start(date("d-m-Y h:i:s"));
        				
		if (isset($_POST['submit_file'])) {
           
			 if ($_POST['kdkppn'] != '') {
                $filter[$no++] = "SUBSTR(KDKPPN,1,3) = '" . $_POST['kdkppn'] . "'";
                $d_kppn = new DataUser($this->registry);
                $this->view->d_nama_kppn = $d_kppn->get_d_user_kppn($_POST['kdkppn']);
            } 		
			
            if ($_POST['kdsatker'] != '') {
                $filter[$no++] = "KDSATKER = '" . $_POST['kdsatker'] . "'";
				$this->view->nmsatker = $d_spm1->get_kdsatker_blu($_POST['kdsatker']);
            }
			
			if ($_POST['kdba'] != '') {
                $filter[$no++] = "BA = '" . $_POST['kdba'] . "'";
				$select[$no++] = "BA";
				$group[$no++] = "BA";
				$this->view->kdba = $_POST['kdba'];
            }
			
		
		$this->view->data = $d_spm1->get_monitoring_akun($select, $filter, $group);
		}
		
		if (Session::get('role') == KPPN) {
			$filter[$no++] = "KDKPPN = '" . Session::get('id_user')."'";			
        }
		$this->view->data_ba = $d_spm1->get_list_ba($filter);
		
		$d_kppn_list = new DataUser($this->registry);
        $this->view->kppn_list = $d_kppn_list->get_kppn_kanwil();       
        
        // untuk mengambil data last update 
        $d_last_update = new DataLastUpdate($this->registry);
        $this->view->last_update = $d_last_update->get_last_updatenya($d_spm1->get_table1());
        //var_dump($d_last_update->get_last_updatenya($d_spm1->get_table1()));
		
		$d_log->tambah_log("Sukses");
		
		
        $this->view->render('blu/MonitoringAkun');
    }
	
	public function overviewBLU($mode=null) {

      $fetch = new DataOverview($this->registry);
	  
      $dashLRAHariIni = $fetch->getLRAMenkeu();

      $belanjaPerpres = $fetch->getAPBNBelanja();
      $penerimaanPerpres = $fetch->getAPBNPenerimaan();
      $pembiayaanPerpres = $fetch->getAPBNPembiayaan();

      $dipaHariIni = $fetch->sumDIPABelanja();
      $pembiayaanHariIni = $fetch->sumRealisasiPembiayaanMenkeu();
      $belanjaHariIni = $fetch->sumRealisasiBelanjaMenkeu();
      $penerimaanHariIni = $fetch->sumRealisasiPenerimaanMenkeu();

      $kontrakHariIni =  $fetch->fetchStatusRealisasiKontrak();

      $belanjaBungaHariIni = $fetch->sumRealisasiBelanjaBunga();
      $belanjaBungaDIPA = $fetch->sumPaguBelanjaBungaMenkeu();
	  
      $pengembalianPenerimaanHariIni = $fetch->sumPengembalianPenerimaanMenkeu();
	  
	  
		
	 /*	
      if (!isset($mode) || ($mode == 1)) {

        $belanjaPerpresTahunLalu = $fetch->getAPBNBelanjaTAYL();

        $lineBelanjaTahunIni = $fetch->fetchLineBelanja(Session::get('ta'));

        if ((''.Session::get('ta')) == date("Y")) {
          $lineBelanjaTahunLalu = $fetch->fetchLineBelanja(intval(Session::get('ta')) - 1);
        }

        $mainchartData = array();
        $mainchartData2 = array();

        if ((''.Session::get('ta')) == date("Y")) {
          $penerimaanPerpresTahunLalu = $fetch->getAPBNPenerimaanTAYL();
        }

        $linePenerimaanTahunIni = $fetch->fetchLinePenerimaan(Session::get('ta'));

        if ((''.Session::get('ta')) == date("Y")) {
          $linePenerimaanTahunLalu = $fetch->fetchLinePenerimaan(intval(Session::get('ta')) - 1);
        }

        $mainchartData3 = array();
        $mainchartData4 = array();

        if ((''.Session::get('ta')) == date("Y")) {

          $maxx = count($lineBelanjaTahunIni)-1;

        } else {

          $maxx = count($lineBelanjaTahunIni);

        }

        for($i = 0; $i<$maxx; $i++) {

          $mainchartData[] = round($lineBelanjaTahunIni[$i]->get_realisasi() / $belanjaPerpres * 1000) / 10;
          $mainchartData3[] = round($linePenerimaanTahunIni[$i]->get_realisasi() / $penerimaanPerpres * 1000) / 10 * -1;

        }

        if ((''.Session::get('ta')) == date("Y")) {
          for($i = 0; $i<12; $i++) {

            $mainchartData2[] = round($lineBelanjaTahunLalu[$i]->get_realisasi() / $belanjaPerpresTahunLalu * 1000) / 10;
            $mainchartData4[] = round($linePenerimaanTahunLalu[$i]->get_realisasi() / $penerimaanPerpresTahunLalu * 1000) / 10 * -1;

          }
        }

        if ((''.Session::get('ta')) == date("Y")) {

          $main_tile = (object) array(

            'type' => 'line',
            'stacked' => true,
            'disclaimer' => 'Data tahun lalu merupakan data tiap <em><strong>akhir</em></strong> bulan bersangkutan.',
            'title' => 'Perkembangan Realisasi Belanja dan Penerimaan',

            'datasets' => array(

                (object) array(

                  'name' => 'Persentase Realisasi Belanja (Tahun Ini)',
                  'values' => $mainchartData

                  ),
                (object) array(

                  'name' => 'Persentase Realisasi Belanja (Tahun Lalu)',
                  'values' => $mainchartData2

                  )

              ),

            'secondary_datasets' => array(

                (object) array(

                  'name' => 'Persentase Realisasi Penerimaan (Tahun Ini)',
                  'values' => $mainchartData3

                  ),
                (object) array(

                  'name' => 'Persentase Realisasi Penerimaan (Tahun Lalu)',
                  'values' => $mainchartData4

                  )

              ),

            'categories' => array('JAN', 'FEB', 'MAR', 'APR', 'MEI', 'JUN', 'JUL', 'AGU', 'SEP', 'OKT', 'NOV', 'DES'),

            'colors' => array('#ff6666', '#1f77b4')

          );

        } else {

          $main_tile = (object) array(

            'type' => 'line',
            'stacked' => true,
            'title' => 'Perkembangan Realisasi Belanja dan Penerimaan',
            'disclaimer' => 'Data tahun lalu merupakan data tiap <em><strong>akhir</em></strong> bulan bersangkutan.',

            'datasets' => array(

                (object) array(

                  'name' => 'Persentase Realisasi Belanja (Tahun Ini)',
                  'values' => $mainchartData

                  )

              ),

            'secondary_datasets' => array(

                (object) array(

                  'name' => 'Persentase Realisasi Penerimaan (Tahun Ini)',
                  'values' => $mainchartData3

                  )

              ),

            'categories' => array('JAN', 'FEB', 'MAR', 'APR', 'MEI', 'JUN', 'JUL', 'AGU', 'SEP', 'OKT', 'NOV', 'DES'),

            'colors' => array('#ff6666', '#1f77b4')

          );

        }

      }  else if ($mode == 2) {

        $detailRealisasi = $fetch->fetchNominalPaguBelanjaPenerimaanMenkeu();

        $mainchartData = array();
        $mainchartData2 = array();
        $mainchartData3 = array();
        $mainchartData4 = array();

        if ((''.Session::get('ta')) == date("Y")) {

        $disclaimer = 'Realisasi tahun lalu merupakan data sampai dengan <em><strong>akhir</strong></em> bulan ' . date('m') . '/' . (Session::get('ta') - 1);

        } else {

          $disclaimer = 'Realisasi tahun lalu merupakan data sampai dengan <em><strong>akhir</strong></em> bulan 12/' . (Session::get('ta') - 1);

        }

        foreach ($detailRealisasi as $did=>$detailItem) {

          if (substr($detailItem->get_akun(), 0, 1) == '4') {

            $mainchartData2[] = round(($detailItem->get_realisasi() * -1) / $detailItem->get_pagu() * 1000) / 10;
            $mainchartData[] = 0;

            if ($detailItem->get_pagu_lalu() <= 0) {

              $mainchartData3[] = 0;
              $mainchartData4[] = 0;

            } else {

              $mainchartData4[] = round(($detailItem->get_realisasi_lalu() * -1) / $detailItem->get_pagu_lalu() * 1000) / 10;
              $mainchartData3[] = 0;

            }

          } else {
              
            if (((''.Session::get('ta')) != '2015') || ($did != 15)) {
                
                $mainchartData[] = round($detailItem->get_realisasi() / $detailItem->get_pagu() * 1000) / 10;
                $mainchartData2[] = 0;
        
                if ($detailItem->get_pagu_lalu() <= 0) {
        
                  $mainchartData3[] = 0;
                  $mainchartData4[] = 0;
        
                } else {
        
                  $mainchartData3[] = round($detailItem->get_realisasi_lalu() / $detailItem->get_pagu_lalu() * 1000) / 10;
                  $mainchartData4[] = 0;
        
                }
                
            }

          }

        }
        
        if ((''.Session::get('ta')) == '2015') {
            
            $mainchartData[] = round($dashLRAHariIni[49]->get_jumlah() / $dashLRAHariIni[49]->get_apbn() * 1000) / 10;
            $mainchartData2[] = 0;
            
            $mainchartData3[] = round($detailRealisasi[15]->get_realisasi_lalu() / $detailRealisasi[15]->get_pagu_lalu() * 1000) / 10;
            $mainchartData4[] = 0;
            
            $mainchartData[] = round($dashLRAHariIni[50]->get_jumlah() / $dashLRAHariIni[50]->get_apbn() * 1000) / 10;
            $mainchartData2[] = 0;
            
            $mainchartData3[] = 0;
            $mainchartData4[] = 0;
                        
            $mainChartCats = array('Pajak', 'PNBP', 'Hibah', 'Pegawai', 'Barang', 'Modal', 'Bunga', 'Subsidi', 'Hibah', 'BanSos', 'Lain-lain', 'Bagi Hasil', 'DAU', 'DAK', 'OtSus', 'DIY', 'Trans. Lainnya', 'Dana Desa'); 
        
        } else {
            
            $mainChartCats = array('Pajak', 'PNBP', 'Hibah', 'Pegawai', 'Barang', 'Modal', 'Bunga', 'Subsidi', 'Hibah', 'BanSos', 'Lain-lain', 'Bagi Hasil', 'DAU', 'DAK', 'OtSus', 'Trans. Lainnya', 'DIY');
            
        }

        $main_tile = (object) array(

          'type' => 'bar',
          'title' => 'Persentase Realisasi Belanja, Pendapatan dan Hibah',

          'datasets' => array(

              (object) array(

                'name' => 'Persentase Realisasi Penerimaan (Tahun Lalu)',
                'values' => $mainchartData4

                ),

              (object) array(

                'name' => 'Persentase Realisasi Penerimaan',
                'values' => $mainchartData2

                ),

              (object) array(

                'name' => 'Persentase Realisasi Belanja (Tahun Lalu)',
                'values' => $mainchartData3

                ),

              (object) array(

                'name' => 'Persentase Realisasi Belanja',
                'values' => $mainchartData

                )             

            ),

          'categories' => $mainChartCats,

          'groups' => array(

              array('Persentase Realisasi Penerimaan', 'Persentase Realisasi Belanja'),
              array('Persentase Realisasi Penerimaan (Tahun Lalu)', 'Persentase Realisasi Belanja (Tahun Lalu)')

            ),

          'colors' => array('#74baeb', '#1f77b4', '#ffaeae', '#ff6666'),

          'disclaimer' => $disclaimer,

          'rotate_height' => 500

        );

      } else if ($mode == 3) {

        $detailRealisasi = $fetch->fetchNominalPaguBelanjaPenerimaanMenkeu();

        $mainchartData = array();
        $mainchartData2 = array();
        $mainchartData3 = array();
        $mainchartData4 = array();

        if ((''.Session::get('ta')) == date("Y")) {

          $disclaimer = 'Realisasi tahun lalu merupakan data sampai dengan <em><strong>akhir</strong></em> bulan ' . date('m') . '/' . (Session::get('ta') - 1);

        } else {

          $disclaimer = 'Realisasi tahun lalu merupakan data sampai dengan <em><strong>akhir</strong></em> bulan 12/' . (Session::get('ta') - 1);

        }

        foreach ($detailRealisasi as $did=>$detailItem) {

          if (substr($detailItem->get_akun(), 0, 1) == '4') {

            $mainchartData2[] = round($detailItem->get_realisasi() * -1 / 1000000000000, 2);
            $mainchartData[] = 0;

            $mainchartData4[] = round($detailItem->get_realisasi_lalu() * -1 / 1000000000000, 2);
            $mainchartData3[] = 0;

          } else {
              
            if (((''.Session::get('ta')) != '2015') || ($did != 15)) {

                $mainchartData[] = round($detailItem->get_realisasi() / 1000000000000, 2);
                $mainchartData2[] = 0;
    
                $mainchartData3[] = round($detailItem->get_realisasi_lalu() / 1000000000000, 2);
                $mainchartData4[] = 0;
            
            }

          }

        }
        
        if ((''.Session::get('ta')) == '2015') {
            
            $mainchartData[] = round($dashLRAHariIni[49]->get_jumlah() / 1000000000000, 2);
            $mainchartData2[] = 0;
            
            $mainchartData3[] = round($detailRealisasi[15]->get_realisasi_lalu() / 1000000000000, 2);
            $mainchartData4[] = 0;
            
            $mainchartData[] = round($dashLRAHariIni[50]->get_jumlah() / 1000000000000, 2);
            $mainchartData2[] = 0;
            
            $mainchartData3[] = 0;
            $mainchartData4[] = 0;
                        
            $mainChartCats = array('Pajak', 'PNBP', 'Hibah', 'Pegawai', 'Barang', 'Modal', 'Bunga', 'Subsidi', 'Hibah', 'BanSos', 'Lain-lain', 'Bagi Hasil', 'DAU', 'DAK', 'OtSus', 'DIY', 'Trans. Lainnya', 'Dana Desa'); 
        
        } else {
            
            $mainChartCats = array('Pajak', 'PNBP', 'Hibah', 'Pegawai', 'Barang', 'Modal', 'Bunga', 'Subsidi', 'Hibah', 'BanSos', 'Lain-lain', 'Bagi Hasil', 'DAU', 'DAK', 'OtSus', 'Trans. Lainnya', 'DIY');
            
        }

        $main_tile = (object) array(

          'type' => 'bar',
          'stacked' => true,
          'title' => 'Nominal Realisasi Belanja, Pendapatan dan Hibah',

          'datasets' => array(

              (object) array(

                'name' => 'Realisasi Penerimaan Tahun Lalu (Triliun Rupiah)',
                'values' => $mainchartData4

                ),

              (object) array(

                'name' => 'Realisasi Penerimaan (Triliun Rupiah)',
                'values' => $mainchartData2

                ),

              (object) array(

                'name' => 'Realisasi Belanja Tahun Lalu (Triliun Rupiah)',
                'values' => $mainchartData3

                ),

              (object) array(

                'name' => 'Realisasi Belanja (Triliun Rupiah)',
                'values' => $mainchartData

                ),

            ),

          'categories' => $mainChartCats,

          'groups' => array(

              array('Realisasi Penerimaan Tahun Lalu (Triliun Rupiah)', 'Realisasi Belanja Tahun Lalu (Triliun Rupiah)'),
              array('Realisasi Penerimaan (Triliun Rupiah)', 'Realisasi Belanja (Triliun Rupiah)')

            ),

          'colors' => array('#74baeb', '#1f77b4', '#ffaeae', '#ff6666'),

          'disclaimer' => $disclaimer,

          'rotate_height' => 500

        );
        
      } else if ($mode == 4) {

        $realisasiPerUnit = $fetch->fetchRealisasiPaguBelanjaPerBAMenkeu();

        $mainchartData = array();
        $mainchartLabel = array();
        $mainchartLegend = array();
        $mainchartExtras = array();

        $mainchartExtras[0] = array();

        foreach ($realisasiPerUnit as $unitData) { 

          $mainchartData[] = round($unitData->get_realisasi() / $unitData->get_pagu() * 1000) / 10;
          $mainchartExtras[0][] = round($unitData->get_realisasi() / 10000000000) / 100 . ' Triliun';
          $mainchartLabel[] = $unitData->get_unit();

        }

        $legendLabels = $fetch->fetchNamaUnit(5, $mainchartLabel);

        foreach ($mainchartLabel as $lid=>$label) {

          foreach ($legendLabels as $legend) {

            if ($label == $legend->get_kode_unit()) {

              $mainchartLegend[$lid] = $legend->get_nama_unit();

            }

          }

        }

        //var_dump($legendLabels);

        $main_tile = (object) array(

          'type' => 'bar',
          'stacked' => true,
          'title' => 'Persentase Realisasi Belanja per K/L',

          'datasets' => array(

              (object) array(

                'name' => 'Persentase Realisasi',
                'values' => $mainchartData

                )

            ),

          'categories' => $mainchartLabel,
          'tooltips' => $mainchartLegend,
          'tooltip_extras' => $mainchartExtras,
          'rotate_height' => 1200

        );

      } else if ($mode == 5) {

        $realisasiPerUnit = $fetch->fetchRealisasiPaguBelanjaPerBAMenkeu();

        $mainchartData = array();
        $mainchartLabel = array();
        $mainchartLegend = array();

        $mainchartExtras = array();

        $mainchartExtras[0] = array();

        foreach ($realisasiPerUnit as $unitData) { 

          if ($unitData->get_unit() != '999') {

            $mainchartData[] = round($unitData->get_realisasi() / 10000000000) / 100;
            $mainchartExtras[0][] = round($unitData->get_realisasi() / $unitData->get_pagu() * 1000) / 10 . ' %';
            $mainchartLabel[] = $unitData->get_unit();

          } else {

            $disclaimer = 'Realisasi untuk BA999 (Bendahara Umum Negara) sebesar ' . (round($unitData->get_realisasi() / 10000000000) / 100) . ' Triliun (' . round($unitData->get_realisasi() / $unitData->get_pagu() * 1000) / 10 . ' %)';

          }

        }

        $legendLabels = $fetch->fetchNamaUnit(5, $mainchartLabel);

        foreach ($mainchartLabel as $lid=>$label) {

          foreach ($legendLabels as $legend) {

            if ($label == $legend->get_kode_unit()) {

              $mainchartLegend[$lid] = $legend->get_nama_unit();

            }

          }

        }

        $main_tile = (object) array(

          'type' => 'bar',
          'stacked' => true,
          'title' => 'Nominal Realisasi Belanja per K/L (Tidak Termasuk BA 999)',

          'datasets' => array(

              (object) array(

                'name' => 'Nominal Realisasi (dalam Triliun Rupiah)',
                'values' => $mainchartData

                )

            ),

          'categories' => $mainchartLabel,
          'tooltips' => $mainchartLegend,
          'tooltip_extras' => $mainchartExtras,
          'disclaimer' => $disclaimer,
          'rotate_height' => 1200

        );

      } else if ($mode == 6) {

        $realisasiPerUnitPajak = $fetch->fetchRealisasiPenerimaanPajakPerBAMenkeu();
        $realisasiPerUnitPNBP = $fetch->fetchRealisasiPenerimaanPNBPPerBAMenkeu();

        $mainchartData = array();
        $mainchartData2 = array();
        $mainchartLabel = array();
        $mainchartLegend = array();

        foreach ($realisasiPerUnitPajak as $uid=>$unitData) { 

          $mainchartData[] = round($unitData->get_realisasi()/1000000000000, 2);
          $mainchartData2[] = round($realisasiPerUnitPNBP[$uid]->get_realisasi() / 1000000000000, 2);
          $mainchartLabel[] = $unitData->get_unit();

        }

        $legendLabels = $fetch->fetchNamaUnit(5, $mainchartLabel);

        foreach ($mainchartLabel as $lid=>$label) {

          foreach ($legendLabels as $legend) {

            if ($label == $legend->get_kode_unit()) {

              $mainchartLegend[$lid] = $legend->get_nama_unit();

            }

          }

        }

        $main_tile = (object) array(

          'type' => 'bar',
          'stacked' => true,
          'title' => 'Nominal Realisasi Penerimaan per K/L',

          'datasets' => array(

              (object) array(

                'name' => 'Nominal Realisasi Pajak (dalam Triliun Rupiah)',
                'values' => $mainchartData

                ),

              (object) array(

                'name' => 'Nominal Realisasi PNBP (dalam Triliun Rupiah)',
                'values' => $mainchartData2

                )

            ),

          'categories' => $mainchartLabel,
          'tooltips' => $mainchartLegend,
          'rotate_height' => 1200

        );
	
      } else 
	*/  
	  if ($mode == 1) {

        $realisasiPenerimaanPerAkun = $fetch->TargetRealisasiPNBPBLU();

        $mainchartData = array();
        $mainchartData2 = array();
        $mainchartLabel = array();
        $mainchartLegend = array();

        foreach ($realisasiPenerimaanPerAkun as $uid=>$unitData) { 

          $mainchartData[] = round($unitData->get_realisasi()/1000000000, 2);
          $mainchartData2[] = round($unitData->get_pagu() / 1000000000, 2);
          $mainchartLegend[] = $unitData->get_periode();

        }

        $main_tile = (object) array(

          'type' => 'bar',
          //'stacked' => true,
          'title' => '<b>Target, Realisasi PNBP BLU</b>',

          'datasets' => array(

              (object) array(

                'name' => 'Nominal Target (dalam Miliar Rupiah)',
                'values' => $mainchartData2

                ),

              (object) array(

                'name' => 'Nominal Realisasi (dalam Miliar Rupiah)',
                'values' => $mainchartData

                )

            ),

          'categories' => array('2008','2009','2010','2011','2012','2013','2014','2015'),
          'tooltips' => $mainchartLegend,
          'rotate_height' => 1200

        );

      }
	  
	  if ($mode == 2) {

        $PendapatanRumpun = $fetch->PendapatanRumpun();

        $mainchartData = array();
        $mainchartData2 = array();
        $mainchartLabel = array();
        $mainchartLegend = array();
		
        foreach ($PendapatanRumpun as $value) { 
			
		  $pendidikan = $value->get_kesehatan();
          //$mainchartData[] = round($unitData->get_realisasi()/1000000000, 2);
          //$mainchartData2[] = round($unitData->get_pagu() / 1000000000, 2);
          //$mainchartLegend[] = $unitData->get_periode();

        }
		
        $main_tile = (object) array(

                    'type' => 'pie',
                    'title' => 'Proporsi Realisasi Pendapatan Per Rumpun 2015',
                    'datasets' => array(

                        (object) array(

                          'name' => 'Pendidikan',
                          'value' => $pendidikan

                          ),

                        (object) array(

                          'name' => 'Kesehatan',
                          'value' => $PendapatanRumpun->get_kesehatan()

                          ),

                        (object) array(

                          'name' => 'Kawasan',
                          'value' => $PendapatanRumpun->get_kawasan()

                          ),

                        (object) array(

                          'name' => 'Barang dan Jasa Lainnya',
                          'value' => $PendapatanRumpun->get_barang_jasa_lainnya()

                          ),

                        (object) array(

                          'name' => 'Pengelola Dana',
                          'value' => $PendapatanRumpun->get_pengelola_dana()

                          ),
						(object) array(

                          'name' => 'lainnya',
                          'value' => $PendapatanRumpun->get_rumpun_lainnya()

                         )

                      ),

                    'colors' => array('#409ACA', '#F6CE40', '#CF8CD7', '#CCCCCC', '#FF6666', '#FF6655'),

                  

          'categories' => array('2013','2014','2015'),
          'tooltips' => $mainchartLegend,
          'rotate_height' => 1200

        );

      }
	
      if ((''.Session::get('ta')) == date("Y")) {

        $subtitle = 'TAHUN INI SAMPAI DENGAN TANGGAL ' . date('d', time() - 24*60*60) . '/' . date('m');

      } else {

        $subtitle = 'TAHUN ' . Session::get('ta') . ' SAMPAI DENGAN TANGGAL 31/12';

      }

      if (($penerimaanHariIni - $belanjaHariIni) > 0) {

        $surplusDefisitColor = array('#37e564');

      } else if (($penerimaanHariIni - $belanjaHariIni) < ($penerimaanPerpres - $belanjaPerpres)) {

        $surplusDefisitColor = array('#ff6666');

      } else {

        $surplusDefisitColor = array('#ffdd40');

      }

      if (($penerimaanHariIni - $belanjaHariIni + $belanjaBungaHariIni) > 0) {

        $kesPrimerColor = array('#37e564');

      } else if (($penerimaanHariIni - $belanjaHariIni + $belanjaBungaHariIni) < ($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA)) {

        $kesPrimerColor = array('#ff6666');

      } else {

        $kesPrimerColor = array('#ffdd40');

      }
	
	  
	  $PendapatanRumpun = $fetch->PendapatanRumpun();
      $this->view->content = (object) array(

          'title' => 'Dashboard: Data Keuangan BLU',
          'subtitle' => $subtitle,
          'type' => 'overview-default',

          //'extras' => $dashLRAHariIni,

          'disclaimer' => 'Dashboard Direktorat PPK-BLU',
		  
		  
          'status_tiles' => array(
		  
			  (object) array(

                    'type' => 'pie',
                    'title' => 'Proporsi Realisasi Pendapatan Per Rumpun 2015',
                    'datasets' => array(

                        (object) array(

                          'name' => 'Pendidikan',
                          'value' => $PendapatanRumpun->get_pendidikan()

                          ),

                        (object) array(

                          'name' => 'Kesehatan',
                          'value' => $PendapatanRumpun->get_kesehatan()

                          ),

                        (object) array(

                          'name' => 'Kawasan',
                          'value' => $PendapatanRumpun->get_kawasan()

                          ),

                        (object) array(

                          'name' => 'Barang dan Jasa Lainnya',
                          'value' => $PendapatanRumpun->get_barang_jasa_lainnya()

                          ),

                        (object) array(

                          'name' => 'Pengelola Dana',
                          'value' => $PendapatanRumpun->get_pengelola_dana()

                          ),
						(object) array(

                          'name' => 'lainnya',
                          'value' => $PendapatanRumpun->get_rumpun_lainnya()

                         )

                      ),

                    'colors' => array('#409ACA', '#F6CE40', '#CF8CD7', '#CCCCCC', '#FF9900', '#FF6655')

                  )/*,
			
              (object) array(

                  'type' => 'gauge',
                  'title' => 'DIPA Belanja',
                  'subtitle' => round($dipaHariIni / 1000000000000, 2) . ' Triliun (' . round($dipaHariIni / $belanjaPerpres * 1000) / 10 . ' %) <br/>Dari Perpres ' . round($belanjaPerpres / 1000000000000, 2)  .' Triliun',
                  'value' => round($dipaHariIni / 1000000000000, 2),
                  'max_value' => round($belanjaPerpres / 1000000000000, 2)

                ),

              (object) array(

                  'type' => 'gauge',
                  'title' => 'Realisasi Belanja',
                  'subtitle' => round($belanjaHariIni / 1000000000000, 2) . ' Triliun (' . round($belanjaHariIni / $belanjaPerpres * 1000) / 10 . ' %) <br/>Dari Anggaran Belanja ' . round($belanjaPerpres / 1000000000000, 2) .' Triliun ',
                  'value' => round($belanjaHariIni / 1000000000000, 2),
                  'max_value' => round($belanjaPerpres / 1000000000000, 2)

                ),

              (object) array(

                  'type' => 'gauge',
                  'title' => 'Realisasi Pendapatan dan Hibah',
                  'subtitle' => round($penerimaanHariIni / 1000000000000, 2) . ' Triliun (' . round($penerimaanHariIni / $penerimaanPerpres * 1000) / 10 . ' %) <br/>Dari Target Penerimaan ' . round($penerimaanPerpres / 1000000000000, 2) .' Triliun <br/>Setelah dikurangi pengembalian penerimaan ' . round($pengembalianPenerimaanHariIni / 1000000000000, 2)  . ' Triliun',
                  'value' => round($penerimaanHariIni / 1000000000000, 2),
                  'max_value' => round($penerimaanPerpres / 1000000000000, 2)

                ),

              (object) array(

                  'type' => 'gauge',
                  'title' => 'Realisasi Pembiayaan',
                  'subtitle' => round($pembiayaanHariIni / 1000000000000, 2)  . ' Triliun (' . round($pembiayaanHariIni / $pembiayaanPerpres * 1000) / 10 . ' %) <br/>Dari Anggaran Pembiayaan ' . round($pembiayaanPerpres / 1000000000000, 2) .' Triliun ',
                  'value' => round($pembiayaanHariIni / 1000000000000, 2),
                  'max_value' => round($pembiayaanPerpres / 1000000000000, 2)

                ),

              (object) array(

                  'type' => 'dial',
                  'title' => 'Surplus/Defisit',
                  'subtitle' => round(($penerimaanHariIni - $belanjaHariIni) / 1000000000000, 2) . ' Triliun (' . round(($penerimaanHariIni - $belanjaHariIni) / ($penerimaanPerpres - $belanjaPerpres) * 1000) / 10 . ' %) <br/>Dari Defisit Anggaran ' . round(($penerimaanPerpres - $belanjaPerpres) / 1000000000000, 2)  .' Triliun ',
                  'value' => round(($penerimaanHariIni - $belanjaHariIni) / 1000000000000, 2),

                  'max_value' => round(($penerimaanPerpres - $belanjaPerpres) / 1000000000000) * -1,
                  'min_value' => round(($penerimaanPerpres - $belanjaPerpres) / 1000000000000),

                  'green_zones' => array(

                      (object) array( 

                        'from' => 0, 
                        'to' => round(($penerimaanPerpres - $belanjaPerpres) / 1000000000000) * -1

                      )

                    ),

                  'red_zones' => array(

                      (object) array( 

                        'from' => round(($penerimaanPerpres - $belanjaPerpres) / 1000000000000), 
                        'to' => 0

                      )

                    )
				
                ),

              (object) array(

                  'type' => 'dial',
                  'title' => 'Keseimbangan Primer',
                  'subtitle' => round(($penerimaanHariIni - $belanjaHariIni + $belanjaBungaHariIni) / 1000000000000, 2) . ' Triliun (' . round(($penerimaanHariIni - $belanjaHariIni + $belanjaBungaHariIni) / ($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA) * 1000) / 10 . ' %) <br/>Dari Anggaran ' . round(($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA) / 1000000000000, 2) .' Triliun ',
                  'max_value' => round(($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA) / 1000000000000)  * -1,
                  'min_value' => round(($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA) / 1000000000000),
                  'value' => round(($penerimaanHariIni - $belanjaHariIni + $belanjaBungaHariIni) / 1000000000000, 2),

                  'green_zones' => array(

                      (object) array( 

                        'from' => 0, 
                        'to' => round(($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA) / 1000000000000)  * -1

                      )

                    ),

                  'red_zones' => array(

                      (object) array( 

                        'from' => round(($penerimaanPerpres - $belanjaPerpres + $belanjaBungaDIPA) / 1000000000000), 
                        'to' => 0

                      )

                    )

                )
				*/
            ) ,
			
          'main_tile' => $main_tile,

          'disable_notifications' => true

        );
	
      $this->view->switchers = array();
      $this->view->switchers[] = 'Target, Realisasi PNBP BLU';
	  //$this->view->switchers[] = 'Proporsi Pendapatan Per Rumpun';
      $this->view->baseURL = URL . 'dataBLU/overviewBLU/';
      
      //echo(json_encode($this->view->content));

      $this->view->render('Template-Overview');

    }
	
    //author by jhon

    public function __destruct() {
        
    }

}
